package controller

import (
	"github.com/gin-gonic/gin"
	"lab.com/biz"
	"lab.com/request"
)

type cAchievement struct {
	APIBase
}

// Achievement .
var Achievement = cAchievement{}

// List return achievement list (all user)
func (ach *cAchievement) List(c *gin.Context) {
	inputParams := request.AchievementListReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		ach.Resp(c, nil, err)
		return
	}

	res, err := biz.Achievement.List(c, inputParams)
	ach.Resp(c, res, err)
}

// Detail return achievement detail (all user)
func (ach *cAchievement) Detail(c *gin.Context) {
	inputParams := request.AchievementDetailReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		ach.Resp(c, nil, err)
		return
	}

	res, err := biz.Achievement.Detail(c, inputParams)
	ach.Resp(c, res, err)
}

// Add return achievement add (admin)
func (ach *cAchievement) Add(c *gin.Context) {
	inputParams := request.AchievementAddReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		ach.Resp(c, nil, err)
		return
	}

	err := biz.Achievement.Add(c, inputParams)
	ach.Resp(c, nil, err)
}

// Delete return achievement delete (admin)
func (ach *cAchievement) Delete(c *gin.Context) {
	inputParams := request.AchievementDeleteReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		ach.Resp(c, nil, err)
		return
	}

	err := biz.Achievement.Delete(c, inputParams)
	ach.Resp(c, nil, err)
}

// Edit return achievement edit (admin)
func (ach *cAchievement) Edit(c *gin.Context) {
	inputParams := request.AchievementEditReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		ach.Resp(c, nil, err)
		return
	}

	err := biz.Achievement.Edit(c, inputParams)
	ach.Resp(c, nil, err)
}

// Show return achievement show (admin)
func (ach *cAchievement) Show(c *gin.Context) {
	inputParams := request.AchievementShowReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		ach.Resp(c, nil, err)
		return
	}

	err := biz.Achievement.Show(c, inputParams)
	ach.Resp(c, nil, err)
}

// Home return achievement ome (admin)
func (ach *cAchievement) Home(c *gin.Context) {
	inputParams := request.AchievementHomeReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		ach.Resp(c, nil, err)
		return
	}

	err := biz.Achievement.Home(c, inputParams)
	ach.Resp(c, nil, err)
}

// ListInManage return achievement list in manage (admin)
func (ach *cAchievement) ListInManage(c *gin.Context) {
	inputParams := request.AchievementListInManageReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		ach.Resp(c, nil, err)
		return
	}

	res, err := biz.Achievement.ListInManage(c, inputParams)
	ach.Resp(c, res, err)
}
